﻿@using StackExchange.Exceptional
@using StackExchange.Opserver
@using StackExchange.Opserver.Controllers
@model StackExchange.Opserver.Views.Exceptions.ExceptionsModel
@{
    var error = Model.Exception;
    var store = Model.Store?.Name;
    var group = Model.Group?.Name;
    var log = Model.Log?.Name;
}
<div class="error-preview">
@if (error == null)
{
    <div class="alert alert-warning">
        <h5>Error not found.</h5>
        <p>The error was no longer found in the store.</p>
    </div>
}
else
{
    <h6 class="page-header">
        <span class="title-prefix">@error.ApplicationName: </span>
        <strong>@error.Type</strong>
        @if (error.DuplicateCount > 1)
        {
            <span class="text-danger">(x@(error.DuplicateCount.ToComma()))</span>
        }
        <span class="pull-right">
            <a class="text-danger js-clear-all" href="#" data-url="@Url.Action(nameof(ExceptionsController.Delete), new { log = log, group = group, similar = error.GUID, store })">@Icon.X Clear all similar</a>
            <span class="text-muted">|</span>
            <a href="@Url.Action(nameof(ExceptionsController.Exceptions), new { similar = error.GUID, log, group, store })" title="View exceptions with the same message in the same log">View Similar</a>
        </span>
    </h6>
    <p class="small text-danger">@error.Message</p>
    <div class="error-info">
        <pre class="stack dark"><code class="nohighlight">@ExceptionalUtils.StackTrace.HtmlPrettify(error.Detail, Current.Settings.Exceptions.StackTraceSettings).AsHtml()</code></pre>
        <p class="small">occurred <b title="@error.CreationDate.ToLongDateString() at @error.CreationDate.ToLongTimeString()">@error.CreationDate.ToRelativeTime()</b> (@error.CreationDate.ToZuluTime()) on @error.MachineName
    </div>
}
</div>